#include "tcppubliccontroller.h"

TcpPublicController::TcpPublicController() : QObject()
{
    this->tcpserver = new QTcpServer::QTcpServer();
    this->tcpserver->listen();
    connect(this->tcpserver, SIGNAL(newConnection()), this, SLOT(new_connection()));
}

int TcpPublicController::getListeningPort()
{
    return this->tcpserver->serverPort();
}

TcpPublicController::~TcpPublicController()
{
    delete this->tcpserver;
}

void TcpPublicController::new_connection()
{
    while(this->tcpserver->hasPendingConnections())
    {
        PublicContact::ManageConection(this->tcpserver->nextPendingConnection());
    }
}

